// h() render()函数动态创建组件
import SealConfirm from './confirm.vue'
import {h,render} from 'vue'



type Props= {
    title?:string
    text:string
}

const div = document.createElement("div")
div.setAttribute('classs',"confirm-container")
document.body.appendChild(div)

export default function Confirm({title,text}:Props){

    return new Promise((resolve,reject)=>{
        const confirmCallback = ()=>{
            // console.log("点击了确定"); 
            render(null,div)
            // resolve('confirm')
            resolve(undefined)
        }
    
        const cancelCallback = ()=>{
            // console.log("点击了取消");
            render(null,div)
            // reject('cancel')
            reject()
        }
    
        // <Confirm title=xxxx  text=xxx  confirmCallback="confirmCallback"  confirmCallback="confirmCallback"></Confirm>
        const vNode  = h(SealConfirm,{
            confirmCallback,
            cancelCallback,
            title,
            text
        })
        render(vNode,div)
    })


   
}

// Confirm({title:xxxx,text:xxxx})